import { defineStore } from 'pinia'
import axios from 'axios'
import { nanoid } from 'nanoid'

const useLoveTalkStore = defineStore('loveTalk', {
  state() {
    return {
      // 数据列表
      talkList:[
        {id:'1', title: 'usertalk。哈哈哈'}
      ]
    }
  },
  actions:{
    /**
     * 获取数据
     */
    async getTalkList(){
      console.log('执行了吗')
      const res = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json')

      console.log('接口res',res)
      const {
        data: { content: title },
      } = res
      this.talkList.push({ id: nanoid(), title })
    }
  }
})

export default useLoveTalkStore
